<?php
/**
 * Created by PhpStorm.
 * User: minicart
 * Date: 2018/9/29
 * Time: 13:23
 */
namespace app\admin\service;
use app\models\ConsultorModel;
use app\models\StudentModel;

/**
 * Class ConsultorService
 * @package app\admin\service
 */
class ConsultorService
{
    /**
     * 已签约客户
     * @return array
     */
    public function consultor()
    {
        try {
            $page = input('page',1);
            $listRows = input('limit',5);
            $phone = input('phone','');
            $contract_number = input('contract_number','');
            $where = [];
            if($phone) $where['student_id'] = StudentModel::where(['phone'=>$phone])->value('id');
            if($contract_number) $where['contract_number'] = ['like','%'.$contract_number.'%'];
            $order = 'id desc';
            $customers = ConsultorModel::pageLists($where, $page,$listRows, $order);
            return $customers;
        } catch (\Exception $ex) {
            return ['code' => 1, 'msg' => $ex->getMessage()];
        }
    }
}